/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2010
 */

package com.osgix.authorize.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Id;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;

import com.osgix.common.orm.ibatis.BaseEntity;

public class ResourceInfo extends BaseEntity implements java.io.Serializable {
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "ResourceInfo";
	public static final String ALIAS_RESOURCE_ID = "resourceId";
	public static final String ALIAS_RESOURCE_NAME = "resourceName";
	public static final String ALIAS_SUPER_ID = "superId";
	public static final String ALIAS_RESOURCE_TYPE = "resourceType";
	public static final String ALIAS_NOTE = "note";
	public static final String ALIAS_LOAD_TYPE = "loadType";
	public static final String ALIAS_ACCESS_TYPE = "accessType";
	public static final String ALIAS_APP_NAME = "appName";

	//date formats

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
	@Id
	private java.lang.Long resourceId;
	@Length(max = 512)
	private java.lang.String resourceName;

	private java.lang.Long superId;

	private java.lang.Integer resourceType;
	@Length(max = 1024)
	private java.lang.String note;

	private java.lang.Integer loadType;

	private java.lang.Integer accessType;
	@Length(max = 32)
	private java.lang.String appName;

	//columns END

	public ResourceInfo() {
	}

	public ResourceInfo(java.lang.Long resourceId) {
		this.resourceId = resourceId;
	}

	public void setResourceId(java.lang.Long value) {
		this.resourceId = value;
	}

	public java.lang.Long getResourceId() {
		return this.resourceId;
	}

	public void setResourceName(java.lang.String value) {
		this.resourceName = value;
	}

	public java.lang.String getResourceName() {
		return this.resourceName;
	}

	public void setSuperId(java.lang.Long value) {
		this.superId = value;
	}

	public java.lang.Long getSuperId() {
		return this.superId;
	}

	public void setResourceType(java.lang.Integer value) {
		this.resourceType = value;
	}

	public java.lang.Integer getResourceType() {
		return this.resourceType;
	}

	public void setNote(java.lang.String value) {
		this.note = value;
	}

	public java.lang.String getNote() {
		return this.note;
	}

	public void setLoadType(java.lang.Integer value) {
		this.loadType = value;
	}

	public java.lang.Integer getLoadType() {
		return this.loadType;
	}

	public void setAccessType(java.lang.Integer value) {
		this.accessType = value;
	}

	public java.lang.Integer getAccessType() {
		return this.accessType;
	}

	public void setAppName(java.lang.String value) {
		this.appName = value;
	}

	public java.lang.String getAppName() {
		return this.appName;
	}

	private Set privilegeResources = new HashSet(0);

	public void setPrivilegeResources(Set<PrivilegeResource> privilegeResource) {
		this.privilegeResources = privilegeResource;
	}

	public Set<PrivilegeResource> getPrivilegeResources() {
		return privilegeResources;
	}

	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("ResourceId", getResourceId())
				.append("ResourceName", getResourceName()).append("SuperId", getSuperId())
				.append("ResourceType", getResourceType()).append("Note", getNote()).append("LoadType", getLoadType())
				.append("AccessType", getAccessType()).append("AppName", getAppName()).toString();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(getResourceId()).toHashCode();
	}

	public boolean equals(Object obj) {
		if (obj instanceof ResourceInfo == false)
			return false;
		if (this == obj)
			return true;
		ResourceInfo other = (ResourceInfo) obj;
		return new EqualsBuilder().append(getResourceId(), other.getResourceId()).isEquals();
	}
}
